<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="标题" prop="title">
        <el-input v-model="queryParams.title" placeholder="请输入标题" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!-- <el-form-item label="作者" prop="author">
        <el-input
          v-model="queryParams.author"
          placeholder="请输入作者"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="标签id" prop="labelId">
        <el-input v-model="queryParams.labelId" placeholder="请输入标签id" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!-- <el-form-item label="封面图片URL" prop="coverUrl">
        <el-input
          v-model="queryParams.coverUrl"
          placeholder="请输入封面图片URL"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="版权文件URL：pdf，word，img" prop="copyrightUrl">
        <el-input
          v-model="queryParams.copyrightUrl"
          placeholder="请输入版权文件URL：pdf，word，img"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="指定审核人ID" prop="chooseExamineUserid">
        <el-input
          v-model="queryParams.chooseExamineUserid"
          placeholder="请输入指定审核人ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="实际审核人ID" prop="actualExamineUserid">
        <el-input
          v-model="queryParams.actualExamineUserid"
          placeholder="请输入实际审核人ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="指定审核人变更备注" prop="examineUserNotes">
        <el-input
          v-model="queryParams.examineUserNotes"
          placeholder="请输入指定审核人变更备注"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="审核状态" prop="articleExamineState">
        <el-input
          v-model="queryParams.articleExamineState"
          placeholder="请输入审核状态：1：待审核，2：审核中，3：审核通过，4：审核未通过"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否支持评论" prop="isComment">
        <el-input
          v-model="queryParams.isComment"
          placeholder="请输入是否支持评论：False:不支持，true:支持"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="状态" prop="onlineState">
        <el-input v-model="queryParams.onlineState" placeholder="请输入上架状态  1：立即上架，2：定时上架，3：暂不上架" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!-- <el-form-item label="上架时间" prop="onlineTime">
        <el-date-picker clearable
          v-model="queryParams.onlineTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择上架时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="下架时间" prop="offlineTime">
        <el-date-picker clearable
          v-model="queryParams.offlineTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择下架时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="操作人ID" prop="userId">
        <el-input
          v-model="queryParams.userId"
          placeholder="请输入操作人ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="是否群发至微信：false:不发送，true:发送" prop="reportVx">
        <el-input
          v-model="queryParams.reportVx"
          placeholder="请输入是否群发至微信：false:不发送，true:发送"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否删除   true：已删除，false：未删除" prop="isDelete">
        <el-input
          v-model="queryParams.isDelete"
          placeholder="请输入是否删除   true：已删除，false：未删除"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['system:article:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['system:article:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['system:article:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['system:article:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="articleList" @selection-change="handleSelectionChange" style="width: 100%">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="内容id" align="center" prop="articleId" />
      <el-table-column label="内容标题" align="center" prop="title" />
      <el-table-column label="内容摘要" align="center" prop="digest">
        <template slot-scope="scope">
          <span v-if="scope.row.digest&&scope.row.digest.length>35">{{ scope.row.digest.substr(0, 35) }}...</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="作者" align="center" prop="author" /> -->
      <!-- <el-table-column label="标签id" align="center" prop="labelId" /> -->
      <el-table-column label="缩略图" align="center" prop="coverUrl" />
      <!-- <el-table-column label="内容" align="center" prop="content" width="300">
        <template slot-scope="scope">
          <span>{{ scope.row.content.substr(0, 35)}}...</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="版权文件" align="center" prop="copyrightUrl" /> -->
      <!-- <el-table-column label="指定审核人ID" align="center" prop="chooseExamineUserid" />
      <el-table-column label="实际审核人ID" align="center" prop="actualExamineUserid" /> -->
      <!-- <el-table-column label="指定审核人变更备注" align="center" prop="examineUserNotes" /> -->
      <el-table-column label="审核状态" align="center" prop="articleExamineState" />
      <!-- <el-table-column label="是否支持评论" align="center" prop="isComment" /> -->
      <!-- <el-table-column label="上架状态" align="center" prop="onlineState" /> -->
      <el-table-column label="上架时间" align="center" prop="onlineTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.onlineTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="下架时间" align="center" prop="offlineTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.offlineTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="操作人ID" align="center" prop="userId" />
      <!-- <el-table-column label="是否群发至微信" align="center" prop="reportVx" /> -->
      <!-- <el-table-column label="是否删除" align="center" prop="isDelete" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['system:article:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['system:article:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog title="添加创作" :visible.sync="open" width="60%" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px" :inline="true">
        <el-row>
    <el-col :span="12">
      <el-form-item label="内容标题" prop="title">
          <el-input v-model="form.title" placeholder="请输入标题" style="width: 360px;" />
        </el-form-item>
    </el-col>
    <el-col :span="12">
      <el-form-item label="内容摘要" prop="digest">
          <el-input v-model="form.digest" type="textarea" placeholder="请输入内容" :rows="3" maxlength="120" style="width: 360px;" show-word-limit />
        </el-form-item>
    </el-col>
  </el-row>
  <el-row>
    <el-col :span="12">
 
      <el-form-item label="作者" prop="author">
          <el-input v-model="form.author" placeholder="请输入作者" style="width: 360px;" />
        </el-form-item>
        <el-form-item label="标签" prop="labelId">
          <!-- <el-input v-model="form.labelId" placeholder="请输入标签id" /> -->
          <el-select v-model="form.labelId" placeholder="请选择标签" style="width: 360px;">
    <el-option
      v-for="item in biaooptions"
      :key="item.labelId"
      :label="item.labelName"
      :value="item.labelId">
    </el-option>
  </el-select>
        </el-form-item>
      
    </el-col>
    <el-col :span="12">
      <el-form-item label="封面图片" prop="coverUrl">
        <el-button type="primary" @click="choseimg()">选择封面</el-button>
        </el-form-item>
    </el-col>
  </el-row>
  <el-divider></el-divider>
      
      <el-row>
        <el-col :span="24">
          <el-button type="primary" @click="choosevideo()">选择视频</el-button>
          <el-button type="primary" @click="choosewenimg()">选择图片</el-button>

          <el-form-item label="创作内容">
          <editor v-model="form.content" :min-height="300" />
          
        </el-form-item>
        </el-col>
        <!-- <el-col :span="12">
          <el-form-item label="预览">
          <editor v-model="form.content" :min-height="192" />
        </el-form-item>
        </el-col> -->
      </el-row>
  <el-divider></el-divider>
     <el-row>
      <el-col :span="12">
        <el-form-item label="版权文件" prop="coverUrl">
          <el-upload class="upload-demo" drag action="https://jsonplaceholder.typicode.com/posts/" multiple>
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            <!-- <div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过500kb</div> -->
          </el-upload>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="审核人" prop="chooseExamineUserid">
          <el-select v-model="form.chooseExamineUserid" filterable placeholder="请选择审核人">
    <el-option
      v-for="item in pepoptions"
      :key="item.userId"
      :label="item.nickName"
      :value="item.userId">
    </el-option>
  </el-select>
        </el-form-item>
      </el-col>
     </el-row>
 

        <!-- <el-form-item label="指定审核人ID" prop="chooseExamineUserid">
          <el-input v-model="form.chooseExamineUserid" placeholder="请输入指定审核人ID" />
        </el-form-item>
        <el-form-item label="实际审核人ID" prop="actualExamineUserid">
          <el-input v-model="form.actualExamineUserid" placeholder="请输入实际审核人ID" />
        </el-form-item> -->
        <!-- <el-form-item label="指定审核人变更备注" prop="examineUserNotes">
          <el-input v-model="form.examineUserNotes" placeholder="请输入指定审核人变更备注" />
        </el-form-item> -->
        <!-- <el-form-item label="审核状态：1：待审核，2：审核中，3：审核通过，4：审核未通过" prop="articleExamineState">
          <el-input v-model="form.articleExamineState" placeholder="请输入审核状态：1：待审核，2：审核中，3：审核通过，4：审核未通过" />
        </el-form-item> -->
        <el-row>
          <el-col :span="12" >
            <el-form-item label="是否支持评论" prop="isComment">
          <!-- <el-input v-model="form.isComment" placeholder="请输入是否支持评论：False:不支持，true:支持" /> -->
          <el-radio v-model="form.isComment" label="false">不支持</el-radio>
  <el-radio v-model="form.isComment" label="true">支持</el-radio>
        </el-form-item>
          </el-col>
          <el-col :span="12" >
            <el-form-item label="群发平台" prop="reportVx">
              <el-checkbox-group v-model="checkList">
    <el-checkbox label="微信公众号"></el-checkbox>
    <el-checkbox label="公司官网"></el-checkbox>
  </el-checkbox-group>
        </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="上架状态" prop="onlineState">
          <!-- <el-input v-model="form.onlineState" placeholder="请输入上架状态  1：立即上架，2：定时上架，3：暂不上架" /> -->
          <el-radio v-model="form.onlineState" label="1">立即上架</el-radio>
  <el-radio v-model="form.onlineState" label="2">定时上架</el-radio>
  <el-radio v-model="form.onlineState" label="3">暂不上架</el-radio>
        </el-form-item>
        <el-row v-if="form.onlineState=='2'">
          <el-col>
            <el-form-item label="上架时间" prop="onlineState">
              <el-date-picker
      v-model="form.onlineTime"
      type="datetime"
      placeholder="选择日期时间">
    </el-date-picker>
        </el-form-item>
         
          </el-col>
        </el-row>
        <!-- <el-form-item label="上架时间" prop="onlineTime">
          <el-date-picker clearable v-model="form.onlineTime" type="date" value-format="yyyy-MM-dd" placeholder="请选择上架时间">
          </el-date-picker>
        </el-form-item> -->
        <!-- <el-form-item label="下架时间" prop="offlineTime">
          <el-date-picker clearable
            v-model="form.offlineTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择下架时间">
          </el-date-picker>
        </el-form-item> -->
        <!-- <el-form-item label="操作人ID" prop="userId">
          <el-input v-model="form.userId" placeholder="请输入操作人ID" />
        </el-form-item>
    
        <el-form-item label="是否删除   true：已删除，false：未删除" prop="isDelete">
          <el-input v-model="form.isDelete" placeholder="请输入是否删除   true：已删除，false：未删除" />
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog title="选择图片" :visible.sync="dialogVisible" width="60%" :before-close="handleClose">
      <div>
        <div style="width: 50%;margin: 20px auto;">

          <el-steps :active="active" finish-status="success">
            <el-step title="选择图片"></el-step>
            <el-step title="编辑图片"></el-step>
          </el-steps>
        </div>




        <div class="tuuuuuuuu" v-if="active == 1">
          <el-upload class="upload-demo" :action="urll" :on-success="handlePrevieww"
            :on-remove="handleRemovee" :before-remove="beforeRemovee" :on-exceed="handleExceedd"
            :show-file-list="false" :file-list="filetu"
            :headers="headers" 
            >

            <el-button size="small" type="primary">点击上传</el-button>
          </el-upload>
          <div class="imglist">
            <div class="imgitem" v-for="(item,index) in imgList" :key="index" 
            @click="chosetu(item)"
            :class="{ activee: activee == item.imgUrl}"> 
             <img :src="item.imgUrl" alt="">
             <p>{{ item.imgName }}</p>
            </div>
          </div>
          <div style="text-align: center;margin-top: 30px;">

            <pagination v-show="totall > 0" :total="totall" 
                  :page-sizes="[14, 20, 30, 40]"
              :page.sync="queryParamss.pageNum" :limit.sync="queryParamss.pageSize"
        @pagination="getListt" />
            <el-button type="primary" @click="choseconfim()" style="margin-top: 20px;">下一步</el-button>

          </div>
        </div>
        <div v-if="active == 2">
          <el-row>
            <el-col :xs="24" :md="12" :style="{ height: '500px' }">
              <vue-cropper ref="cropper" :img="options.img" :info="true" :autoCrop="options.autoCrop"
                :autoCropWidth="options.autoCropWidth" :autoCropHeight="options.autoCropHeight"
                :fixedBox="options.fixedBox" :outputType="options.outputType" @realTime="realTime" v-if="visible" />
            </el-col>
            <el-col :xs="24" :md="12" :style="{ height: '500px' }">
              <div class="avatar-upload-previeww">
                <img :src="previews.url" :style="previews.img" />
              </div>
            </el-col>
          </el-row>
          <div style="text-align: center;margin-top: 50px;">
            <el-button @click="shangyibu()">上一步</el-button>
            <el-button type="primary" @click="uploadImg">确 定</el-button>
          </div>

        </div>

      </div>

    </el-dialog>
    <el-dialog title="选择图片" :visible.sync="imgshow" width="60%" :before-close="handleClosee">
      <div>
        <div class="tuuuuuuuu" >
          <el-upload class="upload-demo" :action="urll" :on-success="handlePrevieww"
            :on-remove="handleRemovee" :before-remove="beforeRemovee" :on-exceed="handleExceedd"
            :show-file-list="false" :file-list="filetu"
            :headers="headers" 
            >
            <el-button size="small" type="primary">点击上传</el-button>
          </el-upload>
          <div class="imglist">
            <div class="imgitem" v-for="(item,index) in imgList" :key="index" 
            @click="chosetuu(item)"
            :class="{ activeee: activeee == item.imgUrl}"> 
             <img :src="item.imgUrl" alt="">
             <p>{{ item.imgName }}</p>
            </div>
          </div>
          <div style="text-align: center;margin-top: 30px;">

            <pagination v-show="totall > 0" :total="totall" 
                  :page-sizes="[14, 20, 30, 40]"
              :page.sync="queryParamss.pageNum" :limit.sync="queryParamss.pageSize"
        @pagination="getListt" />
            <el-button type="primary" @click="choseconfimm()" style="margin-top: 20px;">确定</el-button>

          </div>
        </div>
      </div>

    </el-dialog>
    <el-dialog title="选择视频" :visible.sync="videoshow" width="60%" :before-close="handleCloseee">
      <div>
        <div class="tuuuuuuuu" >
          
            <el-button size="small" type="primary" @click="govideoadd()">添加视频</el-button>

          <div class="imglist">
            <div class="imgitem" v-for="(item,index) in videoList" :key="index" 
            @click="chosetuuu(item)"
            :class="{ activeeee: activeeee == item.videoUrl}"> 
            <video poster="" controls="true" width="auto" height="auto"><source :src="item.videoUrl" type="video/mp4"/></video>
             <p>{{ item.materialTitle }}</p>
            </div>
          </div>
          <div style="text-align: center;margin-top: 30px;">

            <pagination v-show="totalll > 0" :total="totalll" 
                  :page-sizes="[14, 20, 30, 40]"
              :page.sync="queryParamsss.pageNum" :limit.sync="queryParamsss.pageSize"
        @pagination="getListtt" />
            <el-button type="primary" @click="choseconfimmm()" style="margin-top: 20px;">确定</el-button>

          </div>
        </div>
      </div>

    </el-dialog>
  </div>
</template>

<script>
import { listArticle, getArticle, delArticle, addArticle, updateArticle,goToAdd } from "@/api/system/article";
import { listMaterial, getMaterial, delMaterial, addMaterial, updateMaterial,biaoqian ,delvideo,fengmian} from "@/api/system/material";

import { listImg, getImg, delImg, addImg, updateImg } from "@/api/system/img";
import { getToken } from "@/utils/auth";
import { VueCropper } from "vue-cropper";

export default {
  name: "Article",
  components: { VueCropper },

  data() {
    return {
      headers: { Authorization: "Bearer " + getToken() },

      activee:"",
      active: 1,

      pepoptions:"",
      biaooptions:"",
      checkList:"",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      articleList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      dialogVisible:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        title: null,
        digest: null,
        author: null,
        labelId: null,
        coverUrl: null,
        content: null,
        copyrightUrl: null,
        chooseExamineUserid: null,
        actualExamineUserid: null,
        examineUserNotes: null,
        articleExamineState: null,
        isComment: null,
        onlineState: null,
        onlineTime: null,
        offlineTime: null,
        userId: null,
        reportVx: null,
        isDelete: null,
      },
      queryParamss: {
        pageNum: 1,
        pageSize: 14,
        imgUrl: null,
        imgType: null,
        reportWechat: null,
        wechatUrl: null,
        wechatMediaId: null,
        userId: null,
        isDelete: null,
      },
      queryParamsss: {
        pageNum: 1,
        pageSize: 10,
        materialTitle: null,
        materialDigest: null,
        materialAuthor: null,
        labelId: null,
        coverUrl: null,
        videoUrl: null,
        reportWechat: null,
        wechatUrl: null,
        wechatMediaId: null,
        userId: null,
        isDelete: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      options: {
        img: "", //裁剪图片的地址
        autoCrop: true, // 是否默认生成截图框
        autoCropWidth: 320, // 默认生成截图框宽度
        autoCropHeight: 180, // 默认生成截图框高度
        fixedBox: true, // 固定截图框大小 不允许改变
        outputType: "png" // 默认生成截图为PNG格式
      },
      imgList:"",
      videoList:"",
      urll:"",
      filetu:[],
      totall:0,
      totalll:0,
      visible: true,
      previews: {},
      imgshow:false,
      activeee:"",
      activeeee:"",
   videoshow:false


    };
  },

  created() {
    this.urll = process.env.VUE_APP_BASE_API + "/system/sourceMaterialImg/sourceMaterialImgUpload"

    this.getList();
    this.getzidian()
  },
  methods: {
    govideoadd(){
      this.videoshow=false
      this.open=false
      this.activeeee=""
    this.$router.push({
            path:"/article/material/sourceMaterial",
            query:{
            	type:"1"
            }
        })
  },
    choosewenimg(){
      this.active=1
      this.activee=""
      this.loading = true;
      listImg(this.queryParamss).then(response => {
        this.imgList = response.rows;
        this.totall = response.total;
        this.loading = false;
      });
this.imgshow=true
    },
    choosevideo(){
      this.activeee=""
      this.loading = true;
      listMaterial(this.queryParamsss).then(response => {
        this.videoList = response.rows;
        this.totalll = response.total;
        this.loading = false;
      });
this.videoshow=true
    },
        // 实时预览
        realTime(data) {
      this.previews = data;
    },
         // 上传裁剪图片
         uploadImg() {
      this.$refs.cropper.getCropBlob(data => {
        let formData = new FormData();
        formData.append("avatarfile", data);
        uploadAvatar(formData).then(response => {
      
          this.visible = false;
        });
      });
    },
    chosetu(item){
this.activee=item.imgUrl
    },
    chosetuu(item){
this.activeee=item.imgUrl

    },
    chosetuuu(item){
this.activeeee=item.videoUrl

    },
    shangyibu() {
      this.active = 1
    },
    choseconfim() {
      this.active = 2
      this.options.img=this.activee
    },
    handleRemovee(file) {
    },
    handlePrevieww(file) {
      console.log(file);
      if(file.code==500){
        this.$message.warning(file.msg);
       }else{
        this.getListt()
       }
    },
    handleExceedd(files) {

    },
    beforeRemovee(file) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    handleClosee(done) {
     this.imgshow=false
    },
    handleCloseee(done) {
     this.videoshow=false
    },
    handleClose(done) {
      this.dialogVisible = false
    },
    getListt(){
      this.loading = true;
      listImg(this.queryParamss).then(response => {
        this.imgList = response.rows;
        this.totall = response.total;
        this.loading = false;
      });
    },
    getListtt(){
      this.loading = true;
      listMaterial(this.queryParamsss).then(response => {
        this.videoList = response.rows;
        this.totalll = response.total;
        this.loading = false;
      });
    },
    choseimg() {
      this.active=1
      this.activee=""
      this.loading = true;
      listImg(this.queryParamss).then(response => {
        this.imgList = response.rows;
        this.totall = response.total;
        this.loading = false;
      });
      this.dialogVisible = true
    },
    choseconfimm(){
let imgurl=this.activeee


let aa=`<p><img  src=\"${imgurl}" alt=\"\" data-href=\"\" style=\"width:100%;\"/></p>`
this.form.content=this.form.content+aa
this.imgshow=false
    },
    choseconfimmm(){
let videourl=this.activeeee
let str=`   <div data-w-e-type="video" data-w-e-is-void> <video poster="" controls="true" width="auto" height="auto"><source src="${videourl}" type="video/mp4"/></video> </div><p><br></p>`
this.form.content=this.form.content+str
this.videoshow=false
    },
    upvideo(){
    //   console.log(this.form.content)
    //   if(this.form.content==null){
    //     this.form.content=""
        
    //     let video="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
    // let str=`<iframe class=\"ql-video\" frameborder=\"0\" allowfullscreen=\"true\" src=\"${video}\"></iframe>`
    // this.form.content=this.form.content+str
    //   }else{
    //     let video="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"
    // let str=`<iframe class=\"ql-video\" frameborder=\"0\" allowfullscreen=\"true\" src=\"${video}\"></iframe>`
    // this.form.content=this.form.content+str
    //   }
    let video="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"

 let str=`   <div data-w-e-type="video" data-w-e-is-void> <video poster="" controls="true" width="auto" height="auto"><source src="${video}" type="video/mp4"/></video> </div><p><br></p>`
    
    this.form.content=this.form.content+str
    //   }
    },
    /** 查询【请填写功能名称】列表 */
    getzidian(){
goToAdd({}).then(res=>{
  console.log(res)
  this.biaooptions=res.lableList
  this.pepoptions=res.userList

})
    },
    getList() {
      this.loading = true;
      listArticle(this.queryParams).then(response => {
        this.articleList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        articleId: null,
        title: null,
        digest: null,
        author: null,
        labelId: null,
        coverUrl: null,
        content: null,
        copyrightUrl: null,
        chooseExamineUserid: null,
        actualExamineUserid: null,
        examineUserNotes: null,
        articleExamineState: null,
        isComment: null,
        onlineState: null,
        onlineTime: null,
        offlineTime: null,
        userId: null,
        reportVx: null,
        isDelete: null,
        createTime: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.articleId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加【请填写功能名称】";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const articleId = row.articleId || this.ids
      getArticle(articleId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改【请填写功能名称】";
      });
    },
    /** 提交按钮 */
    submitForm() {
console.log(this.form)
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.articleId != null) {
            updateArticle(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addArticle(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const articleIds = row.articleId || this.ids;
      this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + articleIds + '"的数据项？').then(function () {
        return delArticle(articleIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/article/export', {
        ...this.queryParams
      }, `article_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style>
/* .el-input {
  width: 250px;
} */
.ql-video{
  width: 100%;
  height: 350px;
}

</style>
<style lang="scss" scoped>
.imglist {
  width: 100%;

  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;

  .imgitem {
    width: 135px;
    // height: 135px;
    border: 1px solid #f7f7f7;
    border-radius: 5px;
    padding: 10px;
    margin: 10px;
    text-align: center;
    video{
      width: 100%;
    }
    p{
      overflow: hidden;
      text-overflow: ellipsis; //文本超出块元素时以省略号的形式显示

white-space: nowrap; //规定段落中的文本不进行换行
    }
  }
  .activee{
    border: 1px solid #1890ff;
  }
  .activeee{
    border: 1px solid #1890ff;
  }
  .activeeee{
    border: 1px solid #1890ff;
  }
}
</style>
